package com.example.recycler.fate;

import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.EditText;
import android.widget.Toast;

import java.util.HashSet;
import java.util.Set;

import cn.jpush.android.api.JPushInterface;
import cn.jpush.android.api.TagAliasCallback;

public class MainActivity extends AppCompatActivity {
    private EditText mEdtTag;
    Set<String> Tags=new HashSet<>();
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        mEdtTag = (EditText) findViewById(R.id.edt_tag);
    }

    public void go1(View v) {

        Tags.add(mEdtTag.getText().toString());
        JPushInterface.setTags(this, Tags, new TagAliasCallback() {
            @Override
            public void gotResult(int i, String s, Set<String> set) {
                if (i==0) {
                    System.out.println("qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq");
                    Toast.makeText(MainActivity.this, "标签设置成功", Toast.LENGTH_SHORT).show();
                }
            }
        });

    }

    public void go2(View v) {
        Toast.makeText(this, "点到暂停", Toast.LENGTH_SHORT).show();
        JPushInterface.stopPush(getApplicationContext());

    }
    public void go3(View v) {
        Toast.makeText(this, "重新开始", Toast.LENGTH_SHORT).show();
        JPushInterface.resumePush(getApplicationContext());
    }
    public void go4(View v) {
        Toast.makeText(this, "设置别名", Toast.LENGTH_SHORT).show();
        JPushInterface.setAlias(this, "787534698", new TagAliasCallback() {
            @Override
            public void gotResult(int i, String s, Set<String> set) {
                if (i==0) {
                    Toast.makeText(MainActivity.this, "设置别名成功", Toast.LENGTH_SHORT).show();
                }
            }
        });
    }
    public void go5(View v) {
        Toast.makeText(this, "设置别名和标签", Toast.LENGTH_SHORT).show();

        Tags.add("白尼禄");

        JPushInterface.setAliasAndTags(this, "20170304", Tags, new TagAliasCallback() {
            @Override
            public void gotResult(int i, String s, Set<String> set) {
                Toast.makeText(MainActivity.this, "设置了新的别名和标签", Toast.LENGTH_SHORT).show();
            }
        });
    }

}
